<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
  <title>添加权限</title>
</head>
<body>
<script type="text/javascript">
    Ext.onReady(function () {
        var name = Ext.create('Ext.form.field.Text', {
            fieldLabel: '名称',
            allowBlank: false,
            name: 'name',
            anchor: '100%'
        });

        var financialManagement = Ext.create('Ext.form.RadioGroup', {
            //width : 220,
            fieldLabel: '是否有财务权',
            //hideLabel:true,
            //style:'margin-left:100px;margin-top:20px',
            columns: 2,
            anchor: '100%',
            vertical: false,
            items: [
                {boxLabel: '是', inputValue: '是', name: 'financial_management'},
                {boxLabel: '否', inputValue: '否', name: 'financial_management', checked: true}
            ]
        });

        var salePriceInfo = Ext.create('Ext.form.RadioGroup', {
            //width : 220,
            fieldLabel: '是否可查看销售价格信息',
            //hideLabel:true,
            //style:'margin-left:100px;margin-top:20px',
            //name:'financial_management',
            columns: 2,
            anchor: '100%',
            vertical: false,
            items: [
                {boxLabel: '是', inputValue: '是', name: 'sale_price_info'},
                {boxLabel: '否', inputValue: '否', name: 'sale_price_info', checked: true}
            ]
        });

        var unsafeDiscountAudit = Ext.create('Ext.form.RadioGroup', {
            //width : 220,
            fieldLabel: '非安全折扣审批',
            //hideLabel:true,
            //style:'margin-left:100px;margin-top:20px',
            columns: 2,
            anchor: '100%',
            vertical: false,
            items: [
                {boxLabel: '是', inputValue: '是', name: 'unsafe_discount_audit'},
                {boxLabel: '否', inputValue: '否', name: 'unsafe_discount_audit', checked: true}
            ]
        });

        //跨部门销售订单查询能力
        var crossDeptSaleOrderQuery = Ext.create('Ext.form.RadioGroup', {
            //width : 220,
            fieldLabel: '是否可以跨部门查询销售订单',
            //hideLabel:true,
            //style:'margin-left:100px;margin-top:20px',
            columns: 2,
            anchor: '100%',
            vertical: false,
            items: [
                {boxLabel: '是', inputValue: '是', name: 'cross_dept_sale_order_query'},
                {boxLabel: '否', inputValue: '否', name: 'cross_dept_sale_order_query', checked: true}
            ]
        });

        //跨公司访问能力
        var crossCompany = Ext.create('Ext.form.RadioGroup', {
            //width : 220,
            fieldLabel: '是否可以跨公司访问',
            //hideLabel:true,
            //style:'margin-left:100px;margin-top:20px',
            columns: 2,
            anchor: '100%',
            vertical: false,
            items: [
                {boxLabel: '是', inputValue: '是', name: 'cross_company'},
                {boxLabel: '否', inputValue: '否', name: 'cross_company', checked: true}
            ]
        });

        //最低折扣权限
        var discount = Ext.create('Ext.form.field.Number', {
            fieldLabel: '最低折扣',
            name: 'discount',
            allowBlank: false,
            allowDecimals: true,
            minValue: 0
        })

        var desc = Ext.create('Ext.form.TextArea', {
            fieldLabel: '备注',
            allowBlank: false,
            height: 55,
            name: 'description',
            anchor: '100%'
        });

        //提交按钮
        var addRoleButton = Ext.create('Ext.Button', {
            text: '提交',
            iconCls: 'icon-save',
            handler: function () {
                addRoleButton.setDisabled(true);
                if (newRoleFormPanel.form.isValid()) {
                    newRoleFormPanel.form.submit({
                        success: function (result, resp) {
                            if (resp.result.info.indexOf("成功") >= 0) {
                                newRoleWin.destroy();
                            } else {
                                Ext.MessageBox.show({
                                    title: '消息',
                                    msg: resp.result.info,
                                    buttons: Ext.MessageBox.OK,
                                    icon: Ext.MessageBox.WARNING
                                });
                            }
                            addRoleButton.enable();
                        },
                        failure: function (result, request) {
                            addRoleButton.enable();
                            Ext.MessageBox.show({
                                title: '消息',
                                msg: "通讯失败，请从新操作",
                                buttons: Ext.MessageBox.OK,
                                icon: Ext.MessageBox.WARNING
                            });
                        }
                    });
                }
                else {
                    addRoleButton.enable();

                }
            }
        })

        var newRoleFormPanel = Ext.create('Ext.form.Panel', {
            fieldDefaults: {
                labelWidth: 165,
                labelAlign: 'right'
            },
            width: 400,
            frame: true,
            url: '/admin/createRole',
            method: 'GET',
            items: [name, crossCompany,salePriceInfo,financialManagement, unsafeDiscountAudit, crossDeptSaleOrderQuery, discount, desc],
            buttons: [addRoleButton, {
                text: '关闭',
                iconCls: 'exit',
                handler: function () {
                    newRoleWin.destroy();
                }
            }]
        });
        newRoleFormPanel.render('new_role_form');
    })
</script>
<div id="new_role_form"></div>
</body>
</html>